<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>删除节点</title>
</head>
<body>

<div id="app">
    <h2>标题</h2>
    <p id="p1">段落一</p>
    <p class="p2">段落二</p>
</div>

</body>

<script>
    let app = document.getElementById("app");
    let h2 = document.getElementsByName("h2");
    let p1 = document.getElementById("p1");
    let p2 = document.getElementsByClassName("p2");

    p1.parentElement.removeChild(p1);
</script>

</html>